package pro.vet.DAO;

import java.io.Reader;
import java.util.ArrayList;

import org.apache.ibatis.io.Resources;
import org.apache.ibatis.session.SqlSession;
import org.apache.ibatis.session.SqlSessionFactory;
import org.apache.ibatis.session.SqlSessionFactoryBuilder;

import pro.vet.beans.TipoProveedorBean;

import pro.vet.services.TipoProveedor_Services;

public class TipoProveedor_DAO implements TipoProveedor_Services{

    SqlSessionFactory sqlmapper= null;{
      	 try {
   			
   		
      	 Reader reader = Resources.getResourceAsReader("ConfiguracionIbatis.xml");
      	 
      	 sqlmapper =new  SqlSessionFactoryBuilder().build(reader);
      	 } catch (Exception e) {
   				e.printStackTrace();
   				System.out.println("imprime");
   			}
       }
    
	@Override
	public ArrayList<TipoProveedorBean> listaTipoProveedor() throws Exception {

		ArrayList<TipoProveedorBean> lista = null;
		SqlSession session = sqlmapper.openSession();
		try {
			
			lista= (ArrayList<TipoProveedorBean>)session.selectList("TipoProveedorXML.listar_TipoProveeodr");
			
		} catch (Exception e) {
			e.printStackTrace();
		}finally{ session.close();}
		System.out.println("LISTA::"+lista.get(0).getIdTipoProveedor());
		return lista;
	}

}
